import 'package:flutter/material.dart';

import 'package:get/get.dart';
import 'package:getwidget/components/avatar/gf_avatar.dart';
import 'package:getwidget/getwidget.dart';
import 'package:getwidget/shape/gf_avatar_shape.dart';

import '../controllers/gfavatar_controller.dart';

class GfavatarView extends GetView<GfavatarController> {
  String avatarUrl = 'https://i0.hdslb.com/bfs/face/d857929b564a8aa7c63ac40b32f952841928e2d9.jpg@128w_128h_1o.webp';
  String avatarPath = 'assets/images/cliu.jpg';
  double avatarRadius = 40.0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('头像'),
        centerTitle: true,
      ),
      body: Container(
        margin: EdgeInsets.all(10),
        child: ListView(
          children: [
            Wrap(
              alignment: WrapAlignment.spaceEvenly,
              children: [
                GFAvatar(
                  backgroundImage: NetworkImage(avatarUrl),
                  radius: avatarRadius,
                  shape: GFAvatarShape.standard,
                ),
                GFAvatar(
                  backgroundImage: NetworkImage(avatarUrl),
                  radius: avatarRadius,
                  shape: GFAvatarShape.standard,
                ),
                GFAvatar(
                  backgroundImage: NetworkImage(avatarUrl),
                  radius: avatarRadius,
                  shape: GFAvatarShape.standard,
                ),
                GFAvatar(
                  backgroundImage: NetworkImage(avatarUrl),
                  radius: avatarRadius,
                  shape: GFAvatarShape.standard,
                )
              ],
            ),
            Divider(),

            Wrap(
              alignment: WrapAlignment.spaceEvenly,
              children: [
                GFAvatar(
                  backgroundImage: AssetImage(avatarPath),
                  // radius: avatarRadius,
                  size: GFSize.LARGE
                ),
                GFAvatar(
                  backgroundImage: AssetImage(avatarPath),
                  // radius: avatarRadius,
                  size: GFSize.MEDIUM
                ),
                GFAvatar(
                  backgroundImage: AssetImage(avatarPath),
                  // radius: avatarRadius,
                  size: GFSize.SMALL
                ),
                GFAvatar(
                  backgroundImage: AssetImage(avatarPath),
                  radius: avatarRadius,
                )
              ],
            ),
            Divider(),

            Wrap(
              alignment: WrapAlignment.spaceEvenly,
              children: [
                GFAvatar(
                  backgroundImage: AssetImage(avatarPath),
                  radius: avatarRadius,
                  shape: GFAvatarShape.square,
                ),
                GFAvatar(
                  backgroundImage: AssetImage(avatarPath),
                  radius: avatarRadius,
                  shape: GFAvatarShape.standard,
                ),
                GFAvatar(
                  backgroundImage: AssetImage(avatarPath),
                  radius: avatarRadius,
                  child: Text('cliu', style: Theme.of(context).textTheme.headline4),
                ),
                GFAvatar(
                  backgroundImage: AssetImage(avatarPath),
                  radius: avatarRadius,
                ),
              ],
            ),
            Divider(),

            Wrap(
              alignment: WrapAlignment.spaceEvenly,
              children: [
                GFIconBadge(
                  child: GFAvatar(
                    backgroundImage: AssetImage(avatarPath),
                    radius: avatarRadius - 10,
                  ),
                  counterChild: GFBadge(
                    child: Text("12"),
                    size: GFSize.LARGE,
                    color: GFColors.DANGER,
                    shape: GFBadgeShape.pills,
                  ),
                ),
                GFIconBadge(
                  child: GFAvatar(
                    backgroundImage: AssetImage(avatarPath),
                    radius: avatarRadius - 10,
                  ),
                  position: GFBadgePosition.topStart(),
                  counterChild: GFBadge(
                    child: Text("12"),
                    size: GFSize.LARGE,
                    color: GFColors.DANGER,
                    shape: GFBadgeShape.pills,
                  ),
                ),
                GFIconBadge(
                  child: GFAvatar(
                    backgroundImage: AssetImage(avatarPath),
                    radius: avatarRadius - 10,
                  ),
                  position: GFBadgePosition.bottomEnd(),
                  counterChild: GFBadge(
                    child: Text("12"),
                    size: GFSize.LARGE,
                    color: GFColors.DANGER,
                    shape: GFBadgeShape.pills,
                  ),
                ),
                GFIconBadge(
                  child: GFAvatar(
                    backgroundImage: AssetImage(avatarPath),
                    radius: avatarRadius - 10,
                  ),
                  position: GFBadgePosition.bottomStart(),
                  counterChild: GFBadge(
                    child: Text("12"),
                    size: GFSize.LARGE,
                    color: GFColors.DANGER,
                    shape: GFBadgeShape.pills,
                  ),
                ),
              ],
            ),
            Divider(),

            GFButtonBar(
              alignment: WrapAlignment.spaceEvenly,
              children: <Widget>[
                GFAvatar(
                  backgroundColor: GFColors.PRIMARY,
                  child: Icon(
                    Icons.share,
                    color: Colors.white,
                  ),
                ),
                GFAvatar(
                  backgroundColor: GFColors.SECONDARY,
                  child: Icon(
                    Icons.search,
                    color: Colors.white,
                  ),
                ),
                GFAvatar(
                  backgroundColor: GFColors.SUCCESS,
                  child: Icon(
                    Icons.phone,
                    color: Colors.white,
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
